<?php
require_once("../includes/Student.class.php");
require_once("../includes/Staff.class.php");
require_once("../includes/User_type.class.php");
require_once("../includes/User.class.php");
require_once("../includes/Specialization.class.php");


$ID = $_POST["ID"];
$name = $_POST["name"];
$email = $_POST["email"];
$password = $_POST["password"];
$home_address = $_POST["home_address"];
$phone = $_POST["phone"];
$user_type = $_POST["user_type"];
$gender = $_POST["gender"];
$specialization = $_POST["specialization"];

if ( isset($_POST["level"]) )
{
	$level = $_POST["level"];
}

if ( isset($_POST["subSpecialization"]) )
{
	$subSpecialization = $_POST["subSpecialization"];
}

$user = new User();
$user->set_id($ID);
$user->set_name($name) ;
$user->set_email($email) ;
$user->set_password($password);
$user->set_home_address($home_address);
$user->set_phone($phone);
$user->set_user_type(User_type::find_type_id($user_type)) ;
$user->set_gender($gender) ;
$user->create();


if($user_type == "student")
{
$student = new Student();
$student->set_user_id($ID);
$student->set_major($specialization);
$student->set_minor($subSpecialization );
$student->set_level_id($level);
$student->create();
}
else if( ($user_type == "doctor") || ($user_type == "teacher") )
{
$staff = new Staff();
$staff->set_user_id($ID);
$staff->set_department_ID($specialization);
$staff->create();
}

header("Location: admin_home.php");
?>